using UnityEngine;
using System.Collections;

[RequireComponent(typeof(GravitationManager))]
[RequireComponent(typeof(Rigidbody))]
[RequireComponent(typeof(Collider))]

//creates atmosphere trigger
public class Planet : MonoBehaviour
{	
	public float				_PlanetMass;
	public string				_name;
	public float				_atmosphereSize = .8f;
	public bool					_enableAtmosphere = true;
	public Transform			_atmospherePrefab;
	public bool					_isBigPlanet = false;
	
	// Use this for initialization
	void Start ()
	{
		gameObject.AddComponent( "Rigidbody" );
		gameObject.rigidbody.mass = _PlanetMass;
		gameObject.rigidbody.isKinematic = true;
		

		//creating atmospheere trigger
		Transform _atmosphere = null;
		_atmosphere = Instantiate( _atmospherePrefab ) as Transform;
		_atmosphere.gameObject.name = "SphereTrigger_" + _name;
		_atmosphere.parent = transform;
		_atmosphere.transform.position = gameObject.transform.position;
		SphereCollider _sc = _atmosphere.gameObject.AddComponent<SphereCollider>();
		_atmosphere.gameObject.AddComponent<GravitationManager>();
		_sc.isTrigger = true;
		_sc.transform.localScale = new Vector3( _atmosphereSize, _atmosphereSize, _atmosphereSize );
		if ( !_enableAtmosphere )
			_atmosphere.gameObject.renderer.enabled = false;
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}
